package com.niiwoo.civet.trade.service.local.notify.impl;

import com.niiwoo.civet.trade.dao.entity.Project;
import com.niiwoo.civet.trade.enums.NotifyTypeEnum;
import com.niiwoo.civet.user.dto.request.JPushExtDTO;
import com.niiwoo.civet.user.dto.request.UserLetterRequestDTO;
import com.niiwoo.civet.user.enums.JPushEnum;
import com.niiwoo.civet.user.enums.MessageTemplateKeyEnum;
import com.niiwoo.civet.user.enums.SMSTemplateKeyEnum;
import com.niiwoo.civet.user.enums.UserLetterTypeEnum;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.springframework.stereotype.Component;

@Component
public class ProjectFlowMiscarryCancerManagerNotifier2 extends AbstractInvestNotifier<Project> {

    // TS003 投资人
    // 通知+极光推送: 投资项目流标通知 / 您好，您投资的借款项目【项目名称】已流标。原因为：审核人员手动取消了借款标的。投资金额已退回您的账户，祝您生活愉快！
    // 短信: 您好，您投资的借款项目【项目名称】已流标。原因为：审核人员手动取消了借款标的。投资金额已退回您的账户，祝您生活愉快！
    @Override
    protected UserLetterRequestDTO getUserLetterRequestDTO(UserNotifyInfo info) {
        InvestUserNotifyInfo p = (InvestUserNotifyInfo) info;
        // 站内信参数
        List<Object> investLetterParams = Arrays.asList(p.getProjectId(), p.getProjectTitle());
        // 极光推送参数
        List<Object> investPushParams = Collections.singletonList(p.getProjectTitle());
        // 极光推送页面
        JPushExtDTO investJPushExtDTO = new JPushExtDTO();
        investJPushExtDTO.setRedirectPageEnum(JPushEnum.RedirectPageEnum.NOTICE_LIST_PAGE);
        UserLetterRequestDTO investLetterRequest = new UserLetterRequestDTO();
        // 通知
        investLetterRequest.setLetterTemplateEnum(MessageTemplateKeyEnum.LetterTemplateKeyEnum.PROJECT_FLOW_MISCARRY_CANCER_MANAGER_2);
        investLetterRequest.setLetterTemplateParamList(investLetterParams);
        // 极光推送
        investLetterRequest.setJpushTemplateKeyEnum(MessageTemplateKeyEnum.JPushTemplateKeyEnum.PROJECT_FLOW_MISCARRY_CANCER_MANAGER_2);
        investLetterRequest.setJpushTemplateParamList(investPushParams);
        investLetterRequest.setToUserId(p.getUserId());
        investLetterRequest.setProjectId(p.getProjectId());
        investLetterRequest.setUserLetterTypeEnum(UserLetterTypeEnum.LETTER_AND_JPUSH);
        // 极光推送扩展信息
        investLetterRequest.setJPushExt(investJPushExtDTO);
        return investLetterRequest;
    }

    @Override
    protected SMSTemplateKeyEnum getSMSTemplateKey() {
        return SMSTemplateKeyEnum.PROJECT_FLOW_MISCARRY_CANCER_MANAGER_2;
    }

    @Override
    protected NotifyTypeEnum getType() {
        return NotifyTypeEnum.TS003;
    }

}
